package com.atguigu.outputformat;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class WebDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        //设置使用自定义OutputFormat -- 默认使用的是TextOutputFormat
        job.setOutputFormatClass(MyOutputFormat.class);

        //不使用ReduceTask
        job.setNumReduceTasks(0);

        //设置最终输出的key,value的类型（OutputFormat的key,value的类型）
        job.setOutputKeyClass(LongWritable.class);
        job.setOutputValueClass(Text.class);


        FileInputFormat.setInputPaths(job,new Path("D:\\io\\input7"));
        FileOutputFormat.setOutputPath(job,new Path("D:\\io\\output77"));

        job.waitForCompletion(true);
    }
}
